package org.dromara.quick.chat.controller;

import io.swagger.v3.oas.annotations.Operation;
import lombok.RequiredArgsConstructor;
import org.apache.commons.collections4.CollectionUtils;
import org.dromara.common.core.domain.R;
import org.dromara.common.web.core.BaseController;
import org.dromara.quick.chat.model.bo.create.ImSocialAlbumBO;
import org.dromara.quick.chat.service.ImSocialAlbumService;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @Author: Stars
 * @description 针对表【im_social_album(社交软件中的相册表，用于存储用户相册里的图片信息)】的数据库操作Service
 * @Date: 2025/3/6 22:33
 */
@RequiredArgsConstructor
@RestController
@RequestMapping("/im/social/album")
public class ImSocialAlbumController extends BaseController {

    private final ImSocialAlbumService imSocialAlbumService;

    /****
     * 查询相册
     */
    @Operation(summary = "查询相册")
    @GetMapping("/list")
    public R<?> listImSocialAlbum() {
        return R.ok(imSocialAlbumService.listImSocialAlbum());
    }

    /**
     * 添加相册
     */
    @Operation(summary = "群添加成员")
    @PostMapping("/add")
    public R<?> addImSocialAlbum(@RequestBody List<ImSocialAlbumBO> imSocialAlbumList) {
        if (CollectionUtils.isEmpty(imSocialAlbumList)){
            return R.fail("参数不能为空");
        }
        imSocialAlbumService.addImSocialAlbum(imSocialAlbumList);
        return R.ok();
    }

    /**
     * 更改相册顺序
     */
    @Operation(summary = "更改相册顺序")
    @PostMapping("/update")
    public R<?> updateImSocialAlbum(@RequestBody List<ImSocialAlbumBO> imSocialAlbumList) {
        if (CollectionUtils.isEmpty(imSocialAlbumList)){
            return R.fail("参数不能为空");
        }
        imSocialAlbumService.updateImSocialAlbum(imSocialAlbumList);
        return R.ok();
    }

    /**
     * 删除相册的照片
     */
    @Operation(summary = "删除相册的照片")
    @GetMapping("/delete")
    public R<?> deleteImSocialAlbum(Long id) {
        if (id == null){
            return R.fail("参数不能为空");
        }
        imSocialAlbumService.deleteImSocialAlbum(id);
        return R.ok();
    }
}
